Option Strict Off
Option Explicit On
Module Module1
	
    Private Declare Function ECF_AbreCupomMFD Lib "CONVECF.DLL" (ByVal cCPF As String, ByVal cNome As String, ByVal cEnd As String) As Integer
    Private Declare Function ECF_VendeItem Lib "CONVECF.DLL" (ByVal CodProd As String, ByVal Descr As String, ByVal Aliq As String, ByVal TipQtde As String, ByVal Qtde As String, ByVal CasasDec As Integer, ByVal Preço As String, ByVal TipoDesc As String, ByVal Desc As String) As Integer
    Private Declare Function ECF_AcrescimoDescontoItemMFD Lib "CONVECF.DLL" (ByVal item As String, ByVal AcrescDesc As String, ByVal TipoAcrDesc As String, ByVal Valor As String) As Integer
    Private Declare Function ECF_CancelaItemGenerico Lib "CONVECF.DLL" (ByVal NumItem As String) As Integer
    Private Declare Function ECF_SubTotalizaCupomMFD Lib "CONVECF.DLL" () As Integer
    Private Declare Function ECF_AcrescimoDescontoSubtotalMFD Lib "CONVECF.DLL" (ByVal AcrescDesc As String, ByVal TipoAcrDesc As String, ByVal Valor As String) As Integer
    Private Declare Function ECF_TotalizaCupomMFD Lib "CONVECF.DLL" () As Object
    Private Declare Function ECF_FechaCupom Lib "CONVECF.DLL" (ByVal MeioPag As String, ByVal AcresDesc As String, ByVal TipoAcrDesc As String, ByVal ValAcrDesc As String, ByVal ValorPago As String, ByVal Mens As String) As Integer


    Function CupomFiscal() As Object
        Dim retorno As Object

        Dim cCPF, cNome As Object
        Dim cEnd As String
        Dim I As Integer

        Form1.List1.Items.Clear()

        ' --------Abrir Cupom--------

        cCPF = Space(20)
        cNome = Space(30)
        cEnd = Space(80)

        cCPF = "12.456.789-198"
        cNome = "Nome do consumidor"
        cEnd = "Endereço do consumidor"

        retorno = ECF_AbreCupomMFD(cCPF, cNome, cEnd)
        Form1.List1.Items.Add(" 'ECF_AbreCupomMFD' - Status: " & retorno)

        ' --------Inserir 3 itens--------
        For I = 1 To 3

            retorno = ECF_VendeItem("123456", "Sapato", "1200", "I", "2", 2, "1,35", "%", "0000")
            Form1.List1.Items.Add(" 'ECF_VendeItem'  - Status: " & retorno)

            ' --------Desconto em 3 itens--------
            retorno = ECF_AcrescimoDescontoItemMFD("00" & I, "D", "$", "100")
            Form1.List1.Items.Add(" 'ECF_AcrescimoDescontoItemMFD' - Status: " & retorno)
        Next

        ' --------Cancelar item--------
        retorno = ECF_CancelaItemGenerico("001")
        Form1.List1.Items.Add(" 'ECF_CancelaItemGenerico' - Status: " & retorno)

        ' --------SubTotal do Cupom--------
        retorno = ECF_SubTotalizaCupomMFD
        Form1.List1.Items.Add(" 'ECF_SubTotalizaCupomMFD' - Status: " & retorno)

        ' --------Acréscimo em item--------
        retorno = ECF_AcrescimoDescontoSubtotalMFD("A", "$", "2,00")
        Form1.List1.Items.Add(" 'ECF_AcrescimoDescontoSubtotalMFD' - Status: " & retorno)

        ' ---------Fechar Cupom----------
        retorno = ECF_FechaCupom("Cartão", "A", "%", "0000", "5,40", "Volte sempre !")
        Form1.List1.Items.Add(" 'ECF_FechaCupom' - Status: " & retorno)
    End Function
End Module